import { ethers } from "ethers";

function Header({ account, setAccount }) {

  const connectHandle = async () => {
    const accounts =  await window.ethereum.request({ method: 'eth_requestAccounts' })
    setAccount(accounts[0])
  }

  return (
    <header>
      <p className="brand">fun.pump</p>
      {
        account?
        ( <button className="btn--fancy">
          {`${account.slice(0, 6)}...${account.slice(account.length - 4)}`}
          </button>):
        ( <button className="btn--fancy" onClick={connectHandle}>Connect Wallet</button>)
      }

    </header>
  );
}

export default Header;